<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['base_path']?>public/css/style.css" media="screen" />
        <link rel="shortcut_icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.ico" />
        <link rel="icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.png" />
        <title>Foto</title>
        <script type="text/javascript" src="<?php echo $GLOBALS['base_path']?>public/js/fquery.js"></script>
        <script type="text/javascript" >
                /*var validator = {
                    'photoFile' : {
                            'regex' : /^.*\.(bmp|jpeg|jpg|gif|png)$/,
                            'message' : 'Tipe gambar: bmp|jpeg|jpg|gif|png'
                    }
                }*/
                function init() {
                    calendar("datepicker","date");
                    var elements = getElementsByClassName("pagination", null , null);
                    for (var i in elements) {
                        elements[i].onclick = function() {
                            ajaxGet(this.getAttribute('href') , function(result) {
                                //alert(result);
                                document.getElementById('commentList').innerHTML = result;
                            });
                            return false;
                        }
                    }
                }

        </script>
    </head>
    <body onload="init()">
        <div id="bodyWrapper">
            <?php $this->render('accountbar');?>
            <div class="dummy"></div>
            <?php $this->render('menubar');?>

            <div id="content">
                <h2>Detil Foto</h2>
                <img class="photoFull" width="400px" src="<?php echo $photo->getUrl();?>" alt="" />
                <form id="photoCommentForm" method="post" action="<?php echo $this->createUrl('photo/comment/' . $photo->id)?>">
                    <div class="dtable">
                        <div class="drow">
                            <span class="shead"><label for="description">Deskripsi</label></span>
                            <span>
                                <?php echo $photo->description;?>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="date">Tanggal pengambilan</label></span>
                            <span>
                                <?php echo $photo->taken_date;?>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="comment">Komentar</label></span>
                            <span>
                                <div class="commentDIV" id="commentList">
                                    <?php foreach($walls as $wall) : ?>
                                        <div class="myWallCommentPhoto"><img src="<?php if($wall->getPoster()->getProfilePicture() != NULL) echo $wall->getPoster()->getProfilePicture()->getUrl();?>" alt="" /></div>
                                        <div class="myWallCommentPoster"><a href="<?php echo $this->createUrl('profile/view/' . $wall->getPoster()->id);?>"> <?php echo $wall->getPoster()->fullname;?></a></div>
                                        <div class="myWallCommentContent"><?php echo $wall->content;?></div>
                                    <?php endforeach;?>
                                </div>
                                <?php $pagin->render();?>
                            </span>
                        </div>
                        <div class="drow">
							<span class="shead">Nilai</span>
                            <span><b><?php echo $photo->rating; ?></b></span>
                        </div>
						<?php if ($photo->auth != $this->auth) : ?>
							<div class="drow">
								<span></span>
								<span>
									<a href="<?php echo $this->createUrl('photo/like/' . $photo->id)?>">Suka</a> <a href="<?php echo $this->createUrl('photo/unlike/' . $photo->id)?>">Tidak Suka</a>
								</span>
							</div>
						<?endif;?>
                        <?php if ($photo->comment_rule == PhotoModel::$COMMENT_ALLOWED || $photo->auth == $this->auth) :?>
                        <div class="drow">
                            <span class="shead"><label for="comment">Tambah Komentar</label></span>
                            <span>
                                <textarea name="comment" id="comment" rows="5" cols="30"></textarea>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><input type="submit" value="Tambah Komentar" /></span>
                        </div>
                        <?php endif;?>
                    </div>
                </form>
                <?php if ($photo->auth == $this->auth) :?>
                <form id="photoEditForm" method="post" action="<?php echo $this->createUrl('photo/edit/' . $photo->id)?>">
                    <div class="dtable">
                        <div class="drow">
                            <span class="shead"><label for="description">Dekripsi</label></span>
                            <span>
                                <textarea name="description" id="description" rows="5" cols="30"><?php echo $photo->description;?></textarea>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="keyword">Kata kunci</label></span>
                            <span><input type="text" id="keyword" name="keyword" value="<?php echo $photo->keyword;?>" /></span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="category">Kategori</label></span>
                            <span><input type="text" id="category" name="category" value="<?php echo $photo->category;?>" /></span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="date">Tanggal</label></span>
                            <span>
                                <input type="text" id="date" value="<?php echo $photo->taken_date;?>" name="date" />
                                <a href="#"><img onclick="toggleCalendar(this);return false;" class="dp-choose-date" alt="date" src="<?php echo $GLOBALS['base_path']?>public/img/calendar.png" title="Pilih Tanggal" /></a>
                                <span class="dummy"></span>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="access_rule">Hak Lihat</label></span>
                            <span>
                                <input type="radio" name="access_rule" id="access_rule" value="<?php echo PhotoModel::$ACCESS_EVERY?>" <?php if ($photo->access_rule == PhotoModel::$ACCESS_EVERY) echo "checked";?> /> Bebas<br />
                                <input type="radio" name="access_rule" id="access_rule" value="<?php echo PhotoModel::$ACCESS_LOGIN?>" <?php if ($photo->access_rule == PhotoModel::$ACCESS_LOGIN) echo "checked";?> /> Pengguna saja<br />
                                <input type="radio" name="access_rule" id="access_rule" value="<?php echo PhotoModel::$ACCESS_FOLLOWER?>" <?php if ($photo->access_rule == PhotoModel::$ACCESS_FOLLOWER) echo "checked";?> /> Pengikut saja<br />
                                <input type="radio" name="access_rule" id="access_rule" value="<?php echo PhotoModel::$ACCESS_PRIVATE?>" <?php if ($photo->access_rule == PhotoModel::$ACCESS_PRIVATE) echo "checked";?> /> Pribadi<br />
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="comment_rule">Hak Komentar</label></span>
                            <span>
                                <input type="checkbox" name="comment_rule" <?php if ($photo->comment_rule == PhotoModel::$COMMENT_ALLOWED) echo "checked";?> />
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"><label for="tag">Tag</label></span>
                            <span>
                                <input type="checkbox" name="tags[<?php echo $photo->auth->id?>]" value="checked" <?php if ($photo->isTagged($this->auth)) echo "checked";?> /> <?php echo $photo->auth->getProfileLink();?><br />
                                <?php foreach($photo->auth->getFollowed() as $user) : ?>
                                <input type="checkbox" name="tags[<?php echo $user->id?>]" value="checked" <?php if ($photo->isTagged($user)) echo "checked";?> /> <?php echo $user->getProfileLink();?><br />
                                <?php endforeach; ?>
                            </span>
                        </div>
                        <div class="drow">
                            <span class="shead"></span>
                            <span>
                                <input type="submit" value="Ubah" />
                            </span>
                        </div>
                    </div>
                </form>
                <?php endif;?>
            </div>
        </div>
        <div id="datepicker"></div>
        <script src="<?php echo $GLOBALS['base_path']?>public/js/calendar.js" type="text/javascript"></script>
    </body>
</html>